package com.hoshiicloud.withdraw.controller.common;


import cn.hutool.json.JSONObject;
import com.hoshiicloud.common.controller.BaseController;
import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.withdraw.param.Bank3RealCheckParam;
import com.hoshiicloud.withdraw.service.UserBank3RealCheckService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


/**
 * (UserBank3RealCheck)表控制层
 *
 * @author makejava
 * @since 2019-08-30 15:33:49
 */
@RestController
@RequestMapping("/userBank3RealCheck")
@Slf4j
public class UserBank3RealCheckController extends BaseController {
	/**
	 * 服务对象
	 */
	@Autowired
	private UserBank3RealCheckService userBank3RealCheckService;

	@ApiOperation(value = "姓名身份证银行卡三要素验证")
	@PostMapping("/bank3RealCheck")
	public Response bank3RealCheck(@RequestBody @Valid Bank3RealCheckParam param) {
		JSONObject jsonObject = userBank3RealCheckService.bank3RealCheck(param);

		// 当状态不是01 时 返回错误信息
		if (!"01".equals(jsonObject.getStr("status"))) {
			return Response.failed(jsonObject.getStr("msg"));
		}
		return Response.data(jsonObject.getStr("msg"));
	}
}